import os

base_path = os.path.dirname(__file__)
emojis = []
for i in os.listdir():
    if not i.startswith('text'):
        continue
    try:
        content = {}
        childrens = []
        for j in os.listdir(i):
            # print(os.path.splitext(j)[0])
            if not os.path.split(j)[1].endswith('.png'):
                continue
            children = {}
            children['id'] = os.listdir(i).index(j)
            children['name'] = os.path.splitext(j)[0]
            children['pic'] = os.path.join(r'\public',os.path.join(i,j))
            childrens.append(children)
        # print(childrens)

        content['id'] = os.listdir().index(i)
        content['name'] = '第' + os.listdir().index(i).__str__() + '个'
        content['pic'] = childrens[0].get('pic')
        content['children'] = childrens
        emojis.append(content)
    except NotADirectoryError:
        pass
print(emojis)
# base_path = os.path.dirname(__file__) + r'\text1\受到惊吓.png'
# print()
# print(base_path)
